package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.PageBean;
import com.itheima.mapper.OperatorLogMapper;
import com.itheima.pojo.OperatorLog;
import com.itheima.service.OperatorLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperatorLogServiceImpl implements OperatorLogService {

    @Autowired
    private OperatorLogMapper operatorLogMapper;
    /**
     * 添加日志
     * @param operatorLog
     */
    @Override
    public void addLog(OperatorLog operatorLog) {

    }

    /**
     * 分页查询日志
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public PageBean findByPage(int page, int pageSize) {
        //1 执行查询总数
        //2 设置分页参数
        PageHelper.startPage(page, pageSize);
        //3 执行查询所有数据
        List<OperatorLog> logList = operatorLogMapper.findByPage();
        Page<OperatorLog> pages = (Page<OperatorLog>) logList;

        return new PageBean(pages.getTotal(), pages.getResult());
    }

}
